<!DOCTYPE HTML>
<html>
<head>
    <title><%= __('views.pleaseInput')%></title>
    <% include common/meta.ejs %>
    <% include common/public.ejs %>
    <style>
        .weui_btn {
            position: relative;
            display: block;
            margin-left: auto;
            margin-right: auto;
            padding-left: 14px;
            padding-right: 14px;
            box-sizing: border-box;
            font-size: 20px;
            text-align: center;
            text-decoration: none;
            color: #FFFFFF;
            line-height: 2.433333;
            border-radius: 5px;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
            overflow: hidden;
            top: 60px;
            width: 58%;
            height: 50px;
        }
        .weui_toptips.weui_toptips_visible {
            opacity: 1;
            height: 45px;
            line-height:45px;
            font-weight:800;
            font-size:0.9rem;
        }
        .weui_label {
            display: block;
            width: 66px;
            word-wrap: break-word;
            word-break: break-all;
        }
        .item_des{
            width:70px;
            font-weight: 700;
            padding-right: 20px;
        }
    </style>
</head>
<body>
<form id="user_form">
    <input type="hidden" name="wechat" value="<%= session.openId %>">
    <input type="hidden" name="source" value="2">
<div class="weui_cells weui_cells_form">
    <div class="weui_cell">
        <span class="item_des"><%= __('overview.cellphoneNumber')%></span>
        <div class="weui_cell_bd weui_cell_primary">
            <input class="weui_input" type="text" placeholder="<%= __('overview.inputCellphone')%>"
                   style="border-bottom: #666 1px solid;"
                   name="code" value=""/>
        </div>
    </div>
    <div class="weui_cell">
        <span class="item_des"><%= __('overview.name')%></span>
        <div class="weui_cell_bd weui_cell_primary">
            <input class="weui_input" type="text" placeholder="<%= __('overview.inputName')%>"
                   style="border-bottom: #666 1px solid;"
                   name="name" value=""/>
        </div>
    </div>
    <div class="weui_cell">
        <span class="item_des"><%= __('overview.clientCode')%></span>
        <div class="weui_cell_bd weui_cell_primary">
            <input class="weui_input" type="text" placeholder="<%= __('overview.inputClientCode')%>"
                   style="border-bottom: #666 1px solid;"
                   name="properties._cusCode" value=""/>
        </div>
    </div>
    <div class="weui_cell">
        <span class="item_des"><%= __('overview.storeCode')%></span>
        <div class="weui_cell_bd weui_cell_primary">
            <input class="weui_input" type="text" placeholder="<%= __('overview.inputStoreCode')%>"
                   style="border-bottom: #666 1px solid;"
                   name="properties._shopCode" value=""/>
        </div>
    </div>
</div>
</form>
<a href="javascript:void(0);" class="weui_btn weui_btn_primary sure_btn"><%= __('overview.reistrationBinding')%></a>
<% include common/footer.ejs %>
<script>
"use strict";
$(function () {
    $(".sure_btn").click(function () {
        let data = Dolphin.form.getValue('#user_form');

        if(!data.code){
            $.alert(Dolphin.i18n.get("views.phoneCannotEmpty"));
            return;
        }
        if(!data.name){
            $.alert(Dolphin.i18n.get("views.nameCannotEmpty"));
            return;
        }
        if(!data.properties._cusCode){
            $.alert(Dolphin.i18n.get("views.codeCannotEmpty"));
            return;
        }

        $.showLoading(Dolphin.i18n.get("views.verification")+"......");
        Dolphin.ajax({
            url: '<%= global.config.contextPath == '/' ? '' : global.config.contextPath %>/api/dc8f406dd87c4942ad1c68240aa590c8',
            type: Dolphin.requestMethod.POST,
            data: Dolphin.json2string(data),
            forceUrl: true,
            onSuccess: function (reData) {
                if(reData.success) {
                    location.href = "account?openId=<%= session.openId %>";
                   /* Dolphin.ajax({
                        url: '/collect/setUserDataOfSession',
                        type: Dolphin.requestMethod.POST,
                        data: Dolphin.json2string(reData),
                        success: function (mydata) {
                            /!*alert(mydata)*!/

                        }
                    });*/

                } else {
                    $.alert(reData.msg, Dolphin.i18n.get("views.callError"));
                }
            },
            onComplete: function () {
                $.hideLoading();
            }
        });
    });
})
</script>
</body>
</html>
